home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / NCSA / tn3270 2.4d7 source / NCSA⁄BYU TCP⁄IP / atalk.c next >
Text File  |  1991-12-19  |  4KB  |  154 lines

  1. #ifndef lint
  2. static char *SCCSid = "%W%    (NCSA)    %G%";
  3. #endif
  4. /*
  5. *    atalk.c
  6. *     by Gaige B. Paulsen
  7. ****************************************************************************
  8. *                                                                          *
  9. *      Uses    :                                                               *
  10. *      TCP/IP kernel for NCSA Telnet                                       *
  11. *      by Tim Krauskopf                                                    *
  12. *       with Macintosh code by Gaige B. Paulsen                                 *
  13. *                                                                          *
  14. *      National Center for Supercomputing Applications                     *
  15. *      152 Computing Applications Building                                 *
  16. *      605 E. Springfield Ave.                                             *
  17. *      Champaign, IL  61820                                                *
  18. *                                                                          *
  19. *                                                                          *
  20. ****************************************************************************
  21. *
  22. *    Appletalk init and shutdown (and utility) procs.    
  23. *
  24. *    Called by:
  25. *        dlayer.c
  26. *        mactools.c
  27. *        macutil.c
  28. */
  29.  
  30. #include <stdio.h>
  31.  
  32. #include <AppleTalk.h>
  33. #include <Dialogs.h>
  34. #include <Devices.h>
  35.  
  36. #include "protocol.h"
  37. #include "configrec.h"
  38. #include "data.h"
  39. #include "croft.h"
  40.  
  41. #include "mpw.h"
  42. #include "maclook.h"
  43. #include "menu.h"
  44.  
  45. typedef struct {
  46.     unsigned char    node[26];
  47.     unsigned char    net[2];
  48. } ABusVarStruct, *ABusVarPtr, **ABusVarPtrPtr;
  49.  
  50. extern Listen();
  51. extern char *KIPnameptr;
  52.  
  53. void getATaddress
  54.   (
  55.     int *hi,
  56.     int *low,
  57.     int *node
  58.   )
  59. {
  60.     ABusVarPtr ABusVars;
  61.     ABusVarPtrPtr ABusPtrPtr = (ABusVarPtrPtr) 0x2d8L;
  62.  
  63.     ABusVars = *ABusPtrPtr;
  64.     *hi = ABusVars->net[0];
  65.     *low = ABusVars->net[1];
  66.     *node = ABusVars->node[0];
  67.  
  68. }
  69.  
  70. int atopen
  71.   (
  72.     void
  73.   )
  74. {
  75.     short err;
  76.     short socket=72, refnum, item;
  77.     ABusVarPtr ABusVars;
  78.     ABusVarPtrPtr ABusPtrPtr = (ABusVarPtrPtr) 0x2d8L;
  79.     char buffr[100];
  80.     DialogPtr dtemp;
  81.     MPPParamBlock pb;
  82.  
  83.     err = 0;
  84.  
  85. #ifndef MPW
  86.     err = opendriver("\P.MPP",&refnum);
  87. #else
  88.     err = OpenDriver("\P.MPP",&refnum);
  89. #endif MPW
  90.  
  91.     if (err == 0)
  92.       {
  93.         pb.DDPlistener = (Ptr) Listen;
  94.         pb.DDPsocket = socket;
  95.         err=POpenSkt(&pb, FALSE);
  96.       }
  97.     if (err != 0)
  98.       { 
  99.         sprintf(buffr,"Failed Appletalk initialization (%d)\n",err);
  100.         putln(buffr);
  101. #ifndef MPW
  102.         if (err == -91)
  103.             paramtext(0L, 0L, 0L, "\PCouldn't install Listener");
  104.         else if (err == -97 || err == -98)
  105.             paramtext(0L, 0L, 0L,
  106.                 "\PYou forgot to turn on AppleTalk in the Chooser");
  107.         else if (err == -192)
  108.             paramtext(0L, 0L, 0L, "\PCouldn’t find ‘atpl’ resource");
  109.         else
  110.             paramtext(0L, 0L, 0L, "\PUnknown Error");
  111. #else
  112.         if (err == -91)
  113.             paramtext(0L, 0L, 0L, "Couldn't install Listener");
  114.         else if (err == -97 || err == -98)
  115.             paramtext(0L, 0L, 0L,
  116.                 "You forgot to turn on AppleTalk in the Chooser");
  117.         else if (err == -192)
  118.             paramtext(0L, 0L, 0L, "Couldn’t find ‘atpl’ resource");
  119.         else
  120.             paramtext(0L, 0L, 0L, "Unknown Error");
  121. #endif MPW
  122.         dtemp = GetNewDialog(302, (Ptr) 0L, (WindowPtr) -1L);
  123.         ModalDialog(0L, &item);
  124.         DisposDialog(dtemp);
  125.         quit();
  126.       }
  127.  
  128.     ABusVars = *ABusPtrPtr;
  129.     nnmyaddr[0] = ABusVars->net[0];
  130.     nnmyaddr[1] = ABusVars->net[1];
  131.     nnmyaddr[2] = ABusVars->node[0];
  132.     nnmyaddr[3] = 72;
  133.  
  134.     sprintf(buffr,"Net : %d,  Node : %d",*((unsigned short *)(&(ABusVars->net[0]))),(int)(ABusVars->node[0]));
  135.     putln(buffr);
  136.     return(0);
  137. }
  138.  
  139. int atclose
  140.   (
  141.     void
  142.   )
  143. {
  144.     MPPParamBlock pb;
  145.  
  146.     pb.DDPsocket=72;
  147.     PCloseSkt(&pb, FALSE);
  148.  
  149.     if (KIPnameptr)
  150.         KIPunregister();
  151.  
  152.     return(0);
  153. }
  154.